(function() {
var requests = (function() {
	var list = location.href.split('?')
	list = list[list.length - 1]
	function get(name) {
		var arr,
		reg = new RegExp(name + '=([^&]*)&?')
		if (arr = list.match(reg))
			return unescape(arr[1])
		else
			return ''
	}
	return {
		get: get,
		get list() {
			return list
		}
	}
})()
MY = {
	appId: '20201022000596365',
	key: 'k4EFyfR0vVMNFLyxds_y',
	get random() {
		MY.salt = MY.salt || (Math.random() * Math.pow(10, 10)).toFixed()
		return MY.salt
	},
	word: 'apple',
	get sign() {
		return md5(MY.appId + MY.word + MY.random + MY.key)
	},
	get request() {
		return 'http://api.fanyi.baidu.com/api/trans/vip/translate?q=' + MY.word + '&from=en&to=zh&appid=' + MY.appId + '&salt=' + MY.random + '&sign=' + MY.sign
	}
}
function main() {
	console.log(requests.get('my'))
	var comment = `/**
 * 获取随机数
 * @param  {number} Max 匹配到的最大数字
 * @param  {number} Min 匹配到的最小数字
 * @return {number}
 * @example 
 * getRandomNum(1, 100)   
 */`
	var code = `
getRandomNum(1, 100)
`
	var tree = FHDoc.parse(comment)
	document.body.appendChild(FHDoc.tree2HTML(tree))
	code = FHDoc.codeFormat(code)
	fetch(MY.request, {
		method: 'GET', 
		mode: 'no-cors'
	}).then(res => res.text()).then(data => console.info(data))
	return 0
}
window.addEventListener('load', main)
})()